package main

import (
	"flag"
	"fmt"
)

func main() {
	// 添加命令行参数
	entryFunc := flag.String("entry", "", "指定入口函数名称(例如: main.main)")
	showExternal := flag.Bool("show-external", false, "Show external function calls")
	shouFullPath := flag.Bool("show-fullpath", false, "Show full file path in analysis results")
	projectPath := flag.String("dir", "./", "项目根目录")
	flag.Parse()

	config := &AnalyzerConfig{
		ExcludeDirs: []string{
			".git",
			"vendor",
			"node_modules",
		},
		ExcludePatterns: []string{
			"*_test.go",
			"*.pb.go",
		},
		MaxDepth:     -1, // 无限制递归深度
		ShowExternal: *showExternal,
		ShowFullPath: *shouFullPath,
	}

	analyzer := NewProjectAnalyzer(*config)

	// 分析项目目录
	err := analyzer.AnalyzeDirectory(*projectPath, config)
	if err != nil {
		fmt.Printf("Error analyzing directory: %v\n", err)
		return
	}

	// 分析指定的入口函数
	if *entryFunc != "" {
		analyzer.AnalyzeFromEntry(*entryFunc)
	}
}
